	org 16400
__START_PROGRAM:
	di
	push ix
	push iy
	exx
	push hl
	exx
	ld hl, 0
	add hl, sp
	ld (__CALL_BACK__), hl
	ei
	jp __LABEL__charmap01end
__LABEL__charmap01:
#line 2
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00011000
		defb %00111100
		defb %00111100
		defb %00011000
		defb %00011000
		defb %00000000
		defb %00011000
		defb %00000000
		defb %01101100
		defb %01101100
		defb %01101100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %01101100
		defb %01101100
		defb %11111110
		defb %01101100
		defb %11111110
		defb %01101100
		defb %01101100
		defb %00000000
		defb %00011000
		defb %00111110
		defb %01100000
		defb %00111100
		defb %00000110
		defb %01111100
		defb %00011000
		defb %00000000
		defb %00000000
		defb %11000110
		defb %11001100
		defb %00011000
		defb %00110000
		defb %01100110
		defb %11000110
		defb %00000000
		defb %00111000
		defb %01101100
		defb %00111000
		defb %01110110
		defb %11011100
		defb %11001100
		defb %01110110
		defb %00000000
		defb %00001100
		defb %00001100
		defb %00011000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00001100
		defb %00011000
		defb %00110000
		defb %00110000
		defb %00110000
		defb %00011000
		defb %00001100
		defb %00000000
		defb %00110000
		defb %00011000
		defb %00001100
		defb %00001100
		defb %00001100
		defb %00011000
		defb %00110000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %01100110
		defb %00111100
		defb %11111111
		defb %00111100
		defb %01100110
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00011000
		defb %00011000
		defb %01111110
		defb %00011000
		defb %00011000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00011000
		defb %00001000
		defb %00010000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %01111110
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00011000
		defb %00011000
		defb %00000000
		defb %00000011
		defb %00000110
		defb %00001100
		defb %00011000
		defb %00110000
		defb %01100000
		defb %11000000
		defb %00000000
		defb %00111000
		defb %01001100
		defb %11000110
		defb %11000110
		defb %11000110
		defb %01100100
		defb %00111000
		defb %00000000
		defb %00011000
		defb %00111000
		defb %00011000
		defb %00011000
		defb %00011000
		defb %00011000
		defb %01111110
		defb %00000000
		defb %01111100
		defb %11000110
		defb %00001110
		defb %00111100
		defb %01111000
		defb %11100000
		defb %11111110
		defb %00000000
		defb %11111110
		defb %00001100
		defb %00011000
		defb %00111100
		defb %00000110
		defb %11000110
		defb %01111100
		defb %00000000
		defb %00011100
		defb %00111100
		defb %01101100
		defb %11001100
		defb %11111110
		defb %00001100
		defb %00001100
		defb %00000000
		defb %11111100
		defb %11000000
		defb %11111100
		defb %00000110
		defb %00000110
		defb %11000110
		defb %01111100
		defb %00000000
		defb %00111100
		defb %01100000
		defb %11000000
		defb %11111100
		defb %11000110
		defb %11000110
		defb %01111100
		defb %00000000
		defb %11111110
		defb %00000110
		defb %00001100
		defb %00011000
		defb %00110000
		defb %00110000
		defb %00110000
		defb %00000000
		defb %01111000
		defb %11000100
		defb %11100100
		defb %01111000
		defb %10011110
		defb %10000110
		defb %01111100
		defb %00000000
		defb %01111100
		defb %11000110
		defb %11000110
		defb %01111110
		defb %00000110
		defb %00001100
		defb %01111000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00011000
		defb %00011000
		defb %00000000
		defb %00011000
		defb %00011000
		defb %00000000
		defb %00000000
		defb %00011000
		defb %00011000
		defb %00000000
		defb %00011000
		defb %00001000
		defb %00010000
		defb %00000000
		defb %00001100
		defb %00011000
		defb %00110000
		defb %01100000
		defb %00110000
		defb %00011000
		defb %00001100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %01111110
		defb %00000000
		defb %01111110
		defb %00000000
		defb %00000000
		defb %00110000
		defb %00011000
		defb %00001100
		defb %00000110
		defb %00001100
		defb %00011000
		defb %00110000
		defb %00000000
		defb %01111100
		defb %11000110
		defb %00000110
		defb %00011100
		defb %00110000
		defb %00000000
		defb %00110000
		defb %00000000
		defb %01111100
		defb %11000110
		defb %11011110
		defb %11011110
		defb %11011110
		defb %11000000
		defb %01111100
		defb %00000000
		defb %00111000
		defb %01101100
		defb %11000110
		defb %11000110
		defb %11111110
		defb %11000110
		defb %11000110
		defb %00000000
		defb %11111100
		defb %11000110
		defb %11000110
		defb %11111100
		defb %11000110
		defb %11000110
		defb %11111100
		defb %00000000
		defb %00111100
		defb %01100110
		defb %11000000
		defb %11000000
		defb %11000000
		defb %01100110
		defb %00111100
		defb %00000000
		defb %11111000
		defb %11001100
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11001100
		defb %11111000
		defb %00000000
		defb %11111110
		defb %11000000
		defb %11000000
		defb %11111100
		defb %11000000
		defb %11000000
		defb %11111110
		defb %00000000
		defb %11111110
		defb %11000000
		defb %11000000
		defb %11111100
		defb %11000000
		defb %11000000
		defb %11000000
		defb %00000000
		defb %00111110
		defb %01100000
		defb %11000000
		defb %11001110
		defb %11000110
		defb %01100110
		defb %00111110
		defb %00000000
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11111110
		defb %11000110
		defb %11000110
		defb %11000110
		defb %00000000
		defb %01111110
		defb %00011000
		defb %00011000
		defb %00011000
		defb %00011000
		defb %00011000
		defb %01111110
		defb %00000000
		defb %00000110
		defb %00000110
		defb %00000110
		defb %00000110
		defb %11000110
		defb %11000110
		defb %01111100
		defb %00000000
		defb %11000110
		defb %11001100
		defb %11011000
		defb %11110000
		defb %11111000
		defb %11011100
		defb %11001110
		defb %00000000
		defb %11000000
		defb %11000000
		defb %11000000
		defb %11000000
		defb %11000000
		defb %11000000
		defb %11111110
		defb %00000000
		defb %11000110
		defb %11101110
		defb %11111110
		defb %11111110
		defb %11010110
		defb %11000110
		defb %11000110
		defb %00000000
		defb %11000110
		defb %11100110
		defb %11110110
		defb %11111110
		defb %11011110
		defb %11001110
		defb %11000110
		defb %00000000
		defb %01111100
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11000110
		defb %01111100
		defb %00000000
		defb %11111100
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11111100
		defb %11000000
		defb %11000000
		defb %00000000
		defb %01111100
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11011110
		defb %11001100
		defb %01111010
		defb %00000000
		defb %11111100
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11111000
		defb %11001100
		defb %11000110
		defb %00000000
		defb %01111000
		defb %11001100
		defb %11000000
		defb %01111100
		defb %00000110
		defb %11000110
		defb %01111100
		defb %00000000
		defb %01111110
		defb %00011000
		defb %00011000
		defb %00011000
		defb %00011000
		defb %00011000
		defb %00011000
		defb %00000000
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11000110
		defb %01111100
		defb %00000000
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11101110
		defb %01111100
		defb %00111000
		defb %00010000
		defb %00000000
		defb %11000110
		defb %11000110
		defb %11000110
		defb %11010110
		defb %11111110
		defb %11101110
		defb %11000110
		defb %00000000
		defb %11000110
		defb %11101110
		defb %01111100
		defb %00111000
		defb %01111100
		defb %11101110
		defb %11000110
		defb %00000000
		defb %01100110
		defb %01100110
		defb %01100110
		defb %00111100
		defb %00011000
		defb %00011000
		defb %00011000
		defb %00000000
		defb %11111110
		defb %00001110
		defb %00011100
		defb %00111000
		defb %01110000
		defb %11100000
		defb %11111110
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00111100
		defb %00111100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %01111110
		defb %01111110
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00011000
		defb %00011000
		defb %00000000
		defb %00011000
		defb %00111100
		defb %00111100
		defb %00011000
		defb %00011000
		defb %00000000
		defb %00011000
		defb %00000000
		defb %00111100
		defb %01000010
		defb %10111001
		defb %10000101
		defb %10000101
		defb %10111001
		defb %01000010
		defb %00111100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %10001000
		defb %00000000
		defb %00100010
		defb %00000000
		defb %10001000
		defb %00000000
		defb %00100010
		defb %00000000
		defb %10001000
		defb %10001000
		defb %00100010
		defb %00100010
		defb %10001000
		defb %10001000
		defb %00100010
		defb %00100010
		defb %10001000
		defb %10101010
		defb %00100010
		defb %10101010
		defb %10001000
		defb %10101010
		defb %00100010
		defb %10101010
		defb %11001100
		defb %10101010
		defb %00110011
		defb %10101010
		defb %11001100
		defb %10101010
		defb %00110011
		defb %10101010
		defb %11101110
		defb %10101010
		defb %10111011
		defb %10101010
		defb %11101110
		defb %10101010
		defb %10111011
		defb %10101010
		defb %11101110
		defb %11101110
		defb %10111011
		defb %10111011
		defb %11101110
		defb %11101110
		defb %10111011
		defb %10111011
		defb %11101110
		defb %11111111
		defb %10111011
		defb %11111111
		defb %11101110
		defb %11111111
		defb %10111011
		defb %11111111
		defb %11111111
		defb %11111111
		defb %11111111
		defb %11111111
		defb %11111111
		defb %11111111
		defb %11111111
		defb %11111111
#line 586
__LABEL__charmap01end:
	call _msxvideo9990initsuperimpose
	call _msxvideo9990cleanregisters
	ld a, 194
	push af
	ld a, 8
	push af
	call _msxvideo9990vdp
	ld a, 148
	push af
	ld a, 6
	push af
	call _msxvideo9990vdp
	ld hl, 0
	ld (_i), hl
	jp __LABEL0
__LABEL3:
	ld hl, (_i)
	ld de, 1365
	call __MUL16_FAST
	push hl
	ld hl, (_i)
	ld a, l
	push af
	call _msxvideo9990palette12bit
	ld hl, (_i)
	inc hl
	ld (_i), hl
__LABEL0:
	ld hl, 3
	ld de, (_i)
	or a
	sbc hl, de
	jp nc, __LABEL3
	ld hl, 1028
	push hl
	xor a
	push af
	call _msxvideo9990palette12bit
	ld hl, 3330
	push hl
	ld a, 1
	push af
	call _msxvideo9990palette12bit
	ld hl, 1940
	push hl
	ld a, 2
	push af
	call _msxvideo9990palette12bit
	ld hl, 3559
	push hl
	ld a, 3
	push af
	call _msxvideo9990palette12bit
	ld a, 32
	push af
	ld hl, 21845
	push hl
	ld hl, 65535
	push hl
	ld a, 12
	push af
	xor a
	push af
	ld hl, 212
	push hl
	ld hl, 512
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	call _msxvideo9990command
	ld hl, 5380
	push hl
	xor a
	push af
	call _msxvideo9990vpokelocp
	ld hl, 0
	ld (_x), hl
	jp __LABEL5
__LABEL8:
	xor a
	push af
	call _msxvideo9990vpokeseq
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL5:
	ld hl, 4000
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL8
	ld hl, 0
	ld (_x), hl
	jp __LABEL10
__LABEL13:
	ld a, 85
	push af
	call _msxvideo9990vpokeseq
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL10:
	ld hl, 2000
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL13
	ld hl, 0
	ld (_x), hl
	jp __LABEL15
__LABEL18:
	ld a, 170
	push af
	call _msxvideo9990vpokeseq
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL15:
	ld hl, 1000
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL18
	ld hl, 0
	ld (_x), hl
	jp __LABEL20
__LABEL23:
	ld a, 255
	push af
	call _msxvideo9990vpokeseq
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL20:
	ld hl, 500
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL23
	ld a, 16
	push af
	ld hl, 0
	push hl
	ld hl, 65535
	push hl
	ld a, 12
	push af
	xor a
	push af
	ld hl, 8
	push hl
	ld hl, 8
	push hl
	ld hl, 24
	push hl
	ld hl, 184
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	call _msxvideo9990command
	ld hl, 3
	ld (_ik), hl
	ld hl, 12
	ld (_pp), hl
	ld hl, 33
	ld (_seed), hl
	ld hl, 0
	ld (_x), hl
	jp __LABEL25
__LABEL28:
	ld hl, (_pp)
	ld a, l
	push af
	ld hl, (_ik)
	ld a, l
	push af
	ld de, __LABEL__charmap01
	ld hl, (_x)
	add hl, de
	push hl
	ld hl, (_seed)
	ld de, 74
	call __MODU16
	add hl, hl
	add hl, hl
	add hl, hl
	ex de, hl
	pop hl
	add hl, de
	ld a, (hl)
	push af
	call _ikpp2b
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL25:
	ld hl, 7
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL28
	ld a, 16
	push af
	ld hl, 0
	push hl
	ld hl, 65535
	push hl
	ld a, 12
	push af
	xor a
	push af
	ld hl, 8
	push hl
	ld hl, 8
	push hl
	ld hl, 40
	push hl
	ld hl, 184
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	call _msxvideo9990command
	ld hl, 3
	ld (_ik), hl
	ld hl, 12
	ld (_pp), hl
	ld hl, 33
	ld (_seed), hl
	ld hl, 0
	ld (_x), hl
	jp __LABEL30
__LABEL33:
	ld hl, (_pp)
	ld a, l
	push af
	ld hl, (_ik)
	ld a, l
	push af
	ld de, __LABEL__charmap01
	ld hl, (_x)
	add hl, de
	push hl
	ld hl, (_seed)
	ld de, 74
	call __MODU16
	add hl, hl
	add hl, hl
	add hl, hl
	ex de, hl
	pop hl
	add hl, de
	ld a, (hl)
	push af
	call _ikpp2b
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL30:
	ld hl, 7
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL33
	ld a, 16
	push af
	ld hl, 0
	push hl
	ld hl, 65535
	push hl
	ld a, 12
	push af
	xor a
	push af
	ld hl, 8
	push hl
	ld hl, 8
	push hl
	ld hl, 40
	push hl
	ld hl, 24
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	call _msxvideo9990command
	ld hl, 3
	ld (_ik), hl
	ld hl, 12
	ld (_pp), hl
	ld hl, 31
	ld (_seed), hl
	ld hl, 0
	ld (_x), hl
	jp __LABEL35
__LABEL38:
	ld hl, (_pp)
	ld a, l
	push af
	ld hl, (_ik)
	ld a, l
	push af
	ld de, __LABEL__charmap01
	ld hl, (_x)
	add hl, de
	push hl
	ld hl, (_seed)
	ld de, 74
	call __MODU16
	add hl, hl
	add hl, hl
	add hl, hl
	ex de, hl
	pop hl
	add hl, de
	ld a, (hl)
	push af
	call _ikpp2b
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL35:
	ld hl, 7
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL38
	ld hl, 0
	ld (_e0), hl
	jp __LABEL40
__LABEL43:
	ld hl, 0
	ld (_e1), hl
	jp __LABEL45
__LABEL48:
	ld a, 16
	push af
	ld hl, 0
	push hl
	ld hl, 65535
	push hl
	ld a, 12
	push af
	xor a
	push af
	ld hl, 8
	push hl
	ld hl, 8
	push hl
	ld hl, (_e1)
	ld de, 7
	add hl, de
	add hl, hl
	add hl, hl
	add hl, hl
	push hl
	ld hl, (_e0)
	ld de, 5
	add hl, de
	add hl, hl
	add hl, hl
	add hl, hl
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	call _msxvideo9990command
	ld hl, (_e0)
	ld (_ik), hl
	ld hl, (_e1)
	ld (_pp), hl
	ld hl, 0
	ld (_x), hl
	jp __LABEL50
__LABEL53:
	ld hl, (_pp)
	ld a, l
	push af
	ld hl, (_ik)
	ld a, l
	push af
	ld de, __LABEL__charmap01
	ld hl, (_x)
	add hl, de
	push hl
	ld hl, (_seed)
	ld de, 74
	call __MODU16
	add hl, hl
	add hl, hl
	add hl, hl
	ex de, hl
	pop hl
	add hl, de
	ld a, (hl)
	push af
	call _ikpp2b
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL50:
	ld hl, 7
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL53
	ld hl, (_e1)
	inc hl
	ld (_e1), hl
__LABEL45:
	ld hl, 3
	ld de, (_e1)
	or a
	sbc hl, de
	jp nc, __LABEL48
	ld hl, (_e0)
	inc hl
	ld (_e0), hl
__LABEL40:
	ld hl, 3
	ld de, (_e0)
	or a
	sbc hl, de
	jp nc, __LABEL43
	ld hl, 0
	ld (_e0), hl
	jp __LABEL55
__LABEL58:
	ld hl, (_seed)
	call _msxrnd
	ld (_seed), hl
	ld de, 3
	ld hl, (_seed)
	call __BAND16
	ld (_e1), hl
	ld a, 32
	push af
	ld hl, (_e1)
	ld de, 21845
	call __MUL16_FAST
	push hl
	ld hl, 65535
	push hl
	ld a, 12
	push af
	xor a
	push af
	ld hl, 1
	push hl
	ld hl, 512
	push hl
	ld hl, (_e0)
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	call _msxvideo9990command
	ld hl, (_e0)
	inc hl
	ld (_e0), hl
__LABEL55:
	ld hl, 211
	ld de, (_e0)
	or a
	sbc hl, de
	jp nc, __LABEL58
__LABEL60:
	ld hl, (_seed)
	call _msxrnd
	ld (_seed), hl
	ld h, 0
	ld a, l
	and 63
	ld l, a
	ld (_dx), hl
	ld hl, (_seed)
	call _msxrnd
	ld (_seed), hl
	ld de, 27
	call __MODU16
	ld (_dy), hl
	ld hl, (_seed)
	call _msxrnd
	ld (_seed), hl
	ld de, 3
	ld hl, (_seed)
	call __BAND16
	ld (_ik), hl
	ld hl, (_seed)
	call _msxrnd
	ld (_seed), hl
	ld de, 3
	ld hl, (_seed)
	call __BAND16
	ld (_pp), hl
	ld hl, (_seed)
	call _msxrnd
	ld (_seed), hl
	ld de, 73
	call __MODU16
	ld (_e1), hl
	ld a, 16
	push af
	ld hl, 0
	push hl
	ld hl, 65535
	push hl
	ld a, 12
	push af
	xor a
	push af
	ld hl, 8
	push hl
	ld hl, 8
	push hl
	ld hl, (_dy)
	add hl, hl
	add hl, hl
	add hl, hl
	push hl
	ld hl, (_dx)
	add hl, hl
	add hl, hl
	add hl, hl
	push hl
	ld hl, 0
	push hl
	ld hl, 0
	push hl
	call _msxvideo9990command
	ld hl, 0
	ld (_x), hl
	jp __LABEL62
__LABEL65:
	ld hl, (_pp)
	ld a, l
	push af
	ld hl, (_ik)
	ld a, l
	push af
	ld de, __LABEL__charmap01
	ld hl, (_x)
	add hl, de
	push hl
	ld hl, (_e1)
	add hl, hl
	add hl, hl
	add hl, hl
	ex de, hl
	pop hl
	add hl, de
	ld a, (hl)
	push af
	call _ikpp2b
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL62:
	ld hl, 7
	ld de, (_x)
	or a
	sbc hl, de
	jp nc, __LABEL65
	jp __LABEL60
__LABEL67:
	jp __LABEL67
__LABEL__patterntest01a:
	ld hl, 0
	ld b, h
	ld c, l
__END_PROGRAM:
	di
	ld hl, (__CALL_BACK__)
	ld sp, hl
	exx
	pop hl
	pop iy
	pop ix
	exx
	ei
	ret
__CALL_BACK__:
	DEFW 0
_msxvideo9990initsuperimpose:
	push ix
	ld ix, 0
	add ix, sp
	ld a, 0
	ld bc, 111
	out (c), a
_msxvideo9990initsuperimpose__leave:
	ld sp, ix
	pop ix
	ret
_msxvideo9990cleanregisters:
	push ix
	ld ix, 0
	add ix, sp
	ld hl, 0
	ld (_msxvideo9990cleanregisters_tzrg0l), hl
	jp __LABEL69
__LABEL72:
	ld hl, (_msxvideo9990cleanregisters_tzrg0l)
	ld a, l
	ld bc, 100
	out (c), a
	ld a, 0
	ld bc, 99
	out (c), a
	ld hl, (_msxvideo9990cleanregisters_tzrg0l)
	inc hl
	ld (_msxvideo9990cleanregisters_tzrg0l), hl
__LABEL69:
	ld hl, 23
	ld de, (_msxvideo9990cleanregisters_tzrg0l)
	or a
	sbc hl, de
	jp nc, __LABEL72
_msxvideo9990cleanregisters__leave:
	ld sp, ix
	pop ix
	ret
_msxvideo9990vdp:
	push ix
	ld ix, 0
	add ix, sp
	ld a, (ix+5)
	ld bc, 100
	out (c), a
	ld a, (ix+7)
	ld bc, 99
	out (c), a
_msxvideo9990vdp__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	ex (sp), hl
	exx
	ret
_msxvideo9990palette12bit:
	push ix
	ld ix, 0
	add ix, sp
	ld a, 142
	ld bc, 100
	out (c), a
	ld a, (ix+5)
	add a, a
	add a, a
	ld bc, 99
	out (c), a
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 256
	call __DIVU16
	ld de, 0
	push de
	push hl
	ld de, 0
	ld hl, 15
	call __BAND32
	push de
	push hl
	ld de, 0
	ld hl, 2
	call __MUL32
	ld a, l
	ld bc, 97
	out (c), a
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 16
	call __DIVU16
	ld de, 0
	push de
	push hl
	ld de, 0
	ld hl, 15
	call __BAND32
	push de
	push hl
	ld de, 0
	ld hl, 2
	call __MUL32
	ld a, l
	ld bc, 97
	out (c), a
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 15
	call __BAND16
	add hl, hl
	ld a, l
	ld bc, 97
	out (c), a
_msxvideo9990palette12bit__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	ex (sp), hl
	exx
	ret
_msxvideo9990vpokelocp:
	push ix
	ld ix, 0
	add ix, sp
	ld a, 0
	ld bc, 100
	out (c), a
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 0
	push de
	push hl
	ld de, 0
	ld hl, 255
	call __BAND32
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 256
	call __DIVU16
	ld de, 0
	push de
	push hl
	ld de, 0
	ld hl, 255
	call __BAND32
	ld a, l
	ld bc, 99
	out (c), a
	ld a, (ix+5)
	ld bc, 99
	out (c), a
_msxvideo9990vpokelocp__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	ex (sp), hl
	exx
	ret
_msxvideo9990vpokeseq:
	push ix
	ld ix, 0
	add ix, sp
	ld a, (ix+5)
	ld bc, 96
	out (c), a
_msxvideo9990vpokeseq__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	ex (sp), hl
	exx
	ret
_msxrnd:
#line 2
		ld  d, h
		ld  e, l
		ld  a, d
		ld  h, e
		ld  l, 253
		or  a
		sbc  hl, de
		sbc  a, 0
		sbc  hl, de
		ld  d, 0
		sbc  a, d
		ld  e, a
		sbc  hl, de
		jr  nc, smsrndloop
		inc  hl
smsrndloop:
		ret
#line 19
_msxrnd__leave:
	ret
_msxvideo9990command:
	push ix
	ld ix, 0
	add ix, sp
__LABEL74:
	ld bc, 101
	in a, (c)
	ld h, 1
	and h
	or a
	jp nz, __LABEL74
	ld a, 32
	ld bc, 100
	out (c), a
	ld l, (ix+4)
	ld h, (ix+5)
	ld de, 255
	call __BAND16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+4)
	ld h, (ix+5)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 255
	call __BAND16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+8)
	ld h, (ix+9)
	ld de, 255
	call __BAND16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+8)
	ld h, (ix+9)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+10)
	ld h, (ix+11)
	ld de, 255
	call __BAND16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+10)
	ld h, (ix+11)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+12)
	ld h, (ix+13)
	ld de, 255
	call __BAND16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+12)
	ld h, (ix+13)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+14)
	ld h, (ix+15)
	ld de, 255
	call __BAND16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+14)
	ld h, (ix+15)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 99
	out (c), a
	ld a, (ix+17)
	ld bc, 99
	out (c), a
	ld a, (ix+19)
	ld bc, 99
	out (c), a
	ld l, (ix+20)
	ld h, (ix+21)
	ld de, 255
	call __BAND16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+20)
	ld h, (ix+21)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+22)
	ld h, (ix+23)
	ld de, 255
	call __BAND16
	ld a, l
	ld bc, 99
	out (c), a
	ld l, (ix+22)
	ld h, (ix+23)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 99
	out (c), a
	ld a, 52
	ld bc, 100
	out (c), a
	ld a, (ix+25)
	ld bc, 99
	out (c), a
_msxvideo9990command__leave:
	exx
	ld hl, 22
__EXIT_FUNCTION:
	ld sp, ix
	pop ix
	pop de
	add hl, sp
	ld sp, hl
	push de
	exx
	ret
_ikpp2b:
	push ix
	ld ix, 0
	add ix, sp
	ld hl, 0
	ld (_ikpp2b_tou1), hl
	ld a, 128
	ld (_ikpp2b_tmk1), a
	xor a
	ld (_ikpp2b_tlp1), a
	jp __LABEL76
__LABEL79:
	ld hl, (_ikpp2b_tou1)
	add hl, hl
	add hl, hl
	ld (_ikpp2b_tou1), hl
	ld a, (ix+5)
	ld h, a
	ld a, (_ikpp2b_tmk1)
	and h
	or a
	jp z, __LABEL81
	ld a, (ix+7)
	ld h, 3
	and h
	ld l, a
	ld h, 0
	ex de, hl
	ld hl, (_ikpp2b_tou1)
	call __BOR16
	ld (_ikpp2b_tou1), hl
	jp __LABEL82
__LABEL81:
	ld a, (ix+9)
	ld h, 3
	and h
	ld l, a
	ld h, 0
	ex de, hl
	ld hl, (_ikpp2b_tou1)
	call __BOR16
	ld (_ikpp2b_tou1), hl
__LABEL82:
	ld a, (_ikpp2b_tmk1)
	srl a
	ld (_ikpp2b_tmk1), a
	ld a, (_ikpp2b_tlp1)
	inc a
	ld (_ikpp2b_tlp1), a
__LABEL76:
	ld a, 7
	ld hl, (_ikpp2b_tlp1 - 1)
	cp h
	jp nc, __LABEL79
	ld hl, (_ikpp2b_tou1)
	ld de, 256
	call __DIVU16
	ld a, l
	ld bc, 98
	out (c), a
	ld hl, (_ikpp2b_tou1)
	ld a, l
	ld bc, 98
	out (c), a
_ikpp2b__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	pop bc
	ex (sp), hl
	exx
	ret
#line 1 "and8.asm"
	
	; FASTCALL boolean and 8 version.
	; result in Accumulator (0 False, not 0 True)
; __FASTCALL__ version (operands: A, H)
	; Performs 8bit and 8bit and returns the boolean
	
__AND8:
		or a
		ret z
		ld a, h
		ret 
	
#line 1615 "example08.bas"
#line 1 "band16.asm"
	
; vim:ts=4:et:
	; FASTCALL bitwise and16 version.
	; result in hl 
; __FASTCALL__ version (operands: A, H)
	; Performs 16bit or 16bit and returns the boolean
; Input: HL, DE
; Output: HL <- HL AND DE
	
__BAND16:
		ld a, h
		and d
	    ld h, a
	
	    ld a, l
	    and e
	    ld l, a
	
	    ret 
	
#line 1616 "example08.bas"
#line 1 "band32.asm"
	
	; FASTCALL bitwise and 32 version.
	; Performs 32bit and 32bit and returns the bitwise
	; result in DE,HL
	; First operand in DE,HL 2nd operand into the stack
	
__BAND32:
	    ld b, h
	    ld c, l ; BC <- HL
	
	    pop hl  ; Return address
	    ex (sp), hl ; HL <- Lower part of 2nd Operand
	
		ld a, b
	    and h
	    ld b, a
	
	    ld a, c
	    and l
	    ld c, a ; BC <- BC & HL
	
		pop hl  ; Return dddress
	    ex (sp), hl ; HL <- High part of 2nd Operand
	
	    ld a, d
	    and h
	    ld d, a
	
	    ld a, e
	    and l
	    ld e, a ; DE <- DE & HL
	
	    ld h, b
	    ld l, c ; HL <- BC  ; Always return DE,HL pair regs
	
	    ret
	
#line 1617 "example08.bas"
#line 1 "bor16.asm"
	
; vim:ts=4:et:
	; FASTCALL bitwise or 16 version.
	; result in HL
; __FASTCALL__ version (operands: A, H)
	; Performs 16bit or 16bit and returns the boolean
; Input: HL, DE
; Output: HL <- HL OR DE
	
__BOR16:
		ld a, h
		or d
	    ld h, a
	
	    ld a, l
	    or e
	    ld l, a
	
	    ret 
	
#line 1618 "example08.bas"
#line 1 "div16.asm"
	
	; 16 bit division and modulo functions 
	; for both signed and unsigned values
	
#line 1 "neg16.asm"
	
	; Negates HL value (16 bit)
__ABS16:
		bit 7, h
		ret z
	
__NEGHL:
		ld a, l			; HL = -HL
		cpl
		ld l, a
		ld a, h
		cpl
		ld h, a
		inc hl
		ret
	
#line 5 "div16.asm"
	
__DIVU16:    ; 16 bit unsigned division
	             ; HL = Dividend, Stack Top = Divisor
	
		;   -- OBSOLETE ; Now uses FASTCALL convention
		;   ex de, hl
	    ;	pop hl      ; Return address
	    ;	ex (sp), hl ; CALLEE Convention
	
__DIVU16_FAST:
	    ld a, h
	    ld c, l
	    ld hl, 0
	    ld b, 16
	
__DIV16LOOP:
	    sll c
	    rla
	    adc hl,hl
	    sbc hl,de
	    jr  nc, __DIV16NOADD
	    add hl,de
	    dec c
	
__DIV16NOADD:
	    djnz __DIV16LOOP
	
	    ex de, hl
	    ld h, a
	    ld l, c
	
	    ret     ; HL = quotient, DE = Mudulus
	
	
	
__MODU16:    ; 16 bit modulus
	             ; HL = Dividend, Stack Top = Divisor
	
	    ;ex de, hl
	    ;pop hl
	    ;ex (sp), hl ; CALLEE Convention
	
	    call __DIVU16_FAST
	    ex de, hl	; hl = reminder (modulus)
					; de = quotient
	
	    ret
	
	
__DIVI16:	; 16 bit signed division
		;	--- The following is OBSOLETE ---
		;	ex de, hl
		;	pop hl
		;	ex (sp), hl 	; CALLEE Convention
	
__DIVI16_FAST:
		ld a, d
		xor h
		ex af, af'		; BIT 7 of a contains result
	
		bit 7, d		; DE is negative?
		jr z, __DIVI16A	
	
		ld a, e			; DE = -DE
		cpl
		ld e, a
		ld a, d
		cpl
		ld d, a
		inc de
	
__DIVI16A:
		bit 7, h		; HL is negative?
		call nz, __NEGHL
	
__DIVI16B:
		call __DIVU16_FAST
		ex af, af'
	
		or a	
		ret p	; return if positive
	    jp __NEGHL
	
		
__MODI16:    ; 16 bit modulus
	             ; HL = Dividend, Stack Top = Divisor
	
	    ;ex de, hl
	    ;pop hl
	    ;ex (sp), hl ; CALLEE Convention
	
	    call __DIVI16_FAST
	    ex de, hl	; hl = reminder (modulus)
					; de = quotient
	
	    ret
	
#line 1619 "example08.bas"
#line 1 "mul16.asm"
	
__MUL16:	; Mutiplies HL with the last value stored into de stack
				; Works for both signed and unsigned
	
			PROC
	
			LOCAL __MUL16LOOP
	        LOCAL __MUL16NOADD
			
			ex de, hl
			pop hl		; Return address
			ex (sp), hl ; CALLEE caller convention
	
;;__MUL16_FAST:	; __FASTCALL ENTRY: HL = 1st operand, DE = 2nd Operand
	;;		ld c, h
	;;		ld a, l	 ; C,A => 1st Operand
	;;
	;;		ld hl, 0 ; Accumulator
	;;		ld b, 16
	;;
;;__MUL16LOOP:
	;;		sra c	; C,A >> 1  (Arithmetic)
	;;		rra
	;;
	;;		jr nc, __MUL16NOADD
	;;		add hl, de
	;;
;;__MUL16NOADD:
	;;		sla e
	;;		rl d
	;;			
	;;		djnz __MUL16LOOP
	
__MUL16_FAST:
	        ld b, 16
	        ld a, d
	        ld c, e
	        ex de, hl
	        ld hl, 0
	
__MUL16LOOP:
	        add hl, hl  ; hl << 1
	        sla c
	        rla         ; a,c << 1
	        jp nc, __MUL16NOADD
	        add hl, de
	
__MUL16NOADD:
	        djnz __MUL16LOOP
	
			ret	; Result in hl (16 lower bits)
	
			ENDP
	
#line 1620 "example08.bas"
#line 1 "mul32.asm"
	
#line 1 "_mul32.asm"
	
	
; Ripped from: http://www.andreadrian.de/oldcpu/z80_number_cruncher.html#moztocid784223
	; Used with permission.
	; Multiplies 32x32 bit integer (DEHL x D'E'H'L')
	; 64bit result is returned in H'L'H L B'C'A C
	
	
__MUL32_64START:
			push hl
			exx
			ld b, h
			ld c, l		; BC = Low Part (A)
			pop hl		; HL = Load Part (B)
			ex de, hl	; DE = Low Part (B), HL = HightPart(A) (must be in B'C')
			push hl
	
			exx
			pop bc		; B'C' = HightPart(A)
			exx			; A = B'C'BC , B = D'E'DE
	
				; multiply routine 32 * 32bit = 64bit
				; h'l'hlb'c'ac = b'c'bc * d'e'de
				; needs register a, changes flags
				;
				; this routine was with tiny differences in the
				; sinclair zx81 rom for the mantissa multiply
	
__LMUL:
	        and     a               ; reset carry flag
	        sbc     hl,hl           ; result bits 32..47 = 0
	        exx
	        sbc     hl,hl           ; result bits 48..63 = 0
	        exx
	        ld      a,b             ; mpr is b'c'ac
	        ld      b,33            ; initialize loop counter
	        jp      __LMULSTART  
	
__LMULLOOP:
	        jr      nc,__LMULNOADD  ; JP is 2 cycles faster than JR. Since it's inside a LOOP
	                                ; it can save up to 33 * 2 = 66 cycles
	                                ; But JR if 3 cycles faster if JUMP not taken!
	        add     hl,de           ; result += mpd
	        exx
	        adc     hl,de
	        exx
	
__LMULNOADD:
	        exx
	        rr      h               ; right shift upper
	        rr      l               ; 32bit of result
	        exx
	        rr      h
	        rr      l
	
__LMULSTART:
	        exx
	        rr      b               ; right shift mpr/
	        rr      c               ; lower 32bit of result
	        exx
	        rra                     ; equivalent to rr a
	        rr      c
	        djnz    __LMULLOOP
	
			ret						; result in h'l'hlb'c'ac
	       
#line 2 "mul32.asm"
	
__MUL32:	; multiplies 32 bit un/signed integer.
				; First operand stored in DEHL, and 2nd onto stack
				; Lowest part of 2nd operand on top of the stack
				; returns the result in DE.HL
			exx
			pop hl	; Return ADDRESS
			pop de	; Low part
			ex (sp), hl ; CALLEE -> HL = High part
			ex de, hl
			call __MUL32_64START
	
__TO32BIT:  ; Converts H'L'HLB'C'AC to DEHL (Discards H'L'HL)
			exx
			push bc
			exx
			pop de
			ld h, a
			ld l, c
			ret
	
	
#line 1621 "example08.bas"
	
ZXBASIC_USER_DATA:
	_msxvideo9990setregisters_tzrg0l EQU 49152
	_msxvideo9990cleanregisters_tzrg0l EQU 49152
	_i EQU 49168
	_x EQU 49180
	_dx EQU 49190
	_dy EQU 49192
	_seed EQU 49206
	_ik EQU 49208
	_pp EQU 49210
	_e0 EQU 49216
	_e1 EQU 49218
	_ikpp8b_tlp1 EQU 49152
	_ikpp8b_tmk1 EQU 49153
	_ikpp2b_tlp1 EQU 49152
	_ikpp2b_tmk1 EQU 49153
	_ikpp2b_tou1 EQU 49154
	_ikpp4b_tlp1 EQU 49152
	_ikpp4b_tmk1 EQU 49153
	_ikpp4b_tou1 EQU 49154
	; Defines DATA END --> HEAP size is 0
ZXBASIC_USER_DATA_END EQU ZXBASIC_MEM_HEAP
	; Defines USER DATA Length in bytes
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
	END
